<template>
  <!-- 订单列表 -->
  <div>
    <div>
      <div class="top">
      
        <div class="one" style="margin-left: 10px;">平台渠道：<span :class="{action:a==key}" @click="ptqd(key)" v-for="(index,key) in channels" :key="key">{{index}}</span>
          <span style="text-align: right;margin-left: 1300px;"><el-switch
            v-model="value3"
            active-color="#409EFF"
            inactive-color="#E6A23C"
            active-text="搜索"
            inactive-text="筛选">
          </el-switch></span>
          </div>
        <div class="srco"  style="margin: 10px 0 0 10px;" >店铺账号：
          <span v-for="(index,key) in shop" :key="key" :class="{action:b==key}" @click="dpzhs(key)">{{index}}</span>
        </div>
        <div v-show="!value3">
        <div  style="margin: 10px 0 0 10px;">国家区域：  <span v-for="(index,key) in guojia" :key="key" class="guojia" :class="{action:c==key}" @click="gjqy(key)">{{index}}</span>
        </div>
        <div class="two"  style="margin: 10px 0 0 10px;">排序方式：
          <span v-for="(index,key) in pxfs" :key="key" class="pxfs" :class="{action:d==key}" @click="pxff(key)">{{index}}</span>
        </div>
      </div>
       <div v-show="value3">
          <div  style="margin: 10px 0 0 10px;">搜索类型：
          <span v-for="(index,key) in sslxs" :key="key" class="sslx" :class="{action:e==key}" @click="sslx(key)">{{index}}</span>
        </div>
         <div style="margin: 30px 0 0 10px;">搜索内容：
            <el-input placeholder="请输入内容"  v-model="input5" style="width:500px;">
            </el-input>
             <el-button icon="el-icon-search" circle @click="hunt"></el-button>
        </div>
       <div class="two" style="margin: 30px 0 0 10px;">排序方式：
          <span v-for="(index,key) in pxfs" :key="key" class="pxfs" :class="{action:d==key}" @click="pxff(key)">{{index}}</span>
        </div>
        </div>
      </div>
     
      <!-- 下拉菜单 -->
      <div style=" margin: 10PX 0 0 10PX;">
          <el-dropdown>
          <el-button type="primary">
            批量操作<i class="el-icon-arrow-down el-icon--right"></i>
          </el-button>
          <el-dropdown-menu slot="dropdown">
        <el-dropdown-item  @click.native="goprint">批量打印面单</el-dropdown-item>
        <el-dropdown-item  @click.native="goShipped">批量发货</el-dropdown-item>
        <el-dropdown-item @click.native="goUnDealed">移入待处理</el-dropdown-item>
          </el-dropdown-menu>
          </el-dropdown>
      </div>
      <div style="text-align: right;"> <el-button
    type="warning" round  @click="sxym">
    更新列表
  </el-button>
    <div>
      <div class="block">
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[10]"
      :page-size="10"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
    </div>
  </div>
  <el-dialog :visible.sync="dialogTableVisible" :close-on-click-modal="false">
    <el-progress :percentage="percentage" :color="customColor"></el-progress>
    <div><span style="color:red">状态</span>{{close}}</div>
    <div v-for="(index,key) in arr " :key="key">
      <div style="line-height: 40px;">{{index}}</div>
    </div>
    <div style="text-align: center">
     <el-button
    type="warning" round  @click="sx">
    确认
  </el-button>
    </div>
    <div>
</div>
  </el-dialog>
  </div>
    
  <div class="container-box">
    <el-table
     @selection-change="changeFun"
      :header-cell-style="tableHeaderColor"
      :data="tableData"
      size="mini"
      border
      style="width: 100%"
    >
    <el-table-column
      type="selection"
      width="55">
    </el-table-column>
     <el-table-column
      type="index"
      width="50">
    </el-table-column>
      <el-table-column  label="商品信息" width="190">
         <template scope="scope">
            <div v-show="scope.row.ting" >
              <el-tooltip content="该订单含有备注信息,点击详情查看详细" placement="top">
              <i class="el-icon-chat-dot-square" style="font-size: 12px;color: #409EFF;">拣</i>
              </el-tooltip>
           </div>
           <div style="color:red;cursor:pointer;" v-for="(index, key) in scope.row.OrderItemId.OrderItemId" :key="key" @click="OrderItemId(scope.$index,key)">{{index}}</div>
           <div v-for="(index, key) in scope.row.imgs.GoodsImage" :key="key">
             <img :src="index"  min-width="70" height="70" />
           </div>
        </template>
      </el-table-column>
      <el-table-column  label="订单号" width="170">
         <template scope="scope">
          <div >{{scope.row.AmazonOrderId}}</div>
        </template>
      </el-table-column>
      <el-table-column  label="订单金额($)" width="100">
        <template scope="scope">
          <div>{{scope.row.USD}}{{scope.row.Amounttwo}}</div>
        </template>
      </el-table-column>
      <el-table-column prop="District" label="收件人[国家]" width="120">
      </el-table-column>
      <el-table-column prop="idtwo" label="订单详细" width="150">
         <template scope="scope">
            <div v-for="(index,key) in scope.row.ASIN.ASIN" :key="key">ASIN：{{index}}</div>
            <div v-for="(index,key) in scope.row.SellerSKU.SellerSKU" :key="key">SKU：{{index}}</div>
          </template>
      </el-table-column>
      <el-table-column prop="day_up_goods" label="时间" width="230">
        <template scope="scope">
            <div style="white-space: pre-line;" v-text="scope.row.day_up_goods" width="40" height="40" class="head_pic"></div>
        </template>
      </el-table-column>
      <el-table-column prop="FaceSheet" label="是否打印面单" width="100">
         <template scope="scope">
            <div>{{scope.row.FaceSheet | flase}}</div>
        </template>
      </el-table-column>
       <el-table-column prop="dTrackingNumdh" label="运单号" width="130 "></el-table-column>
      <el-table-column prop="day_flow" label="订单状态" width="75">
         <template scope="scope">
            <div>{{scope.row.day_flow | zt}}</div>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template scope="scope">
          <el-button type="success" @click="goexpress(scope.$index)" size="mini">打印面单</el-button>
          <el-button type="success" @click="gofahuo(scope.$index)" size="mini">发货</el-button>
        <el-button type="info" @click="details(scope.$index)" size="mini">详情</el-button>
        <el-button type="primary" @click="bz(scope.$index)" icon="el-icon-edit" size="mini">备注</el-button>
        </template>
      </el-table-column>
    </el-table>
  
  </div>

<el-dialog width="80%"  title="<----包裹详情---->" :visible.sync="dialogTableVisible2" :close-on-click-modal="false">
  <div class="xq">
  <el-row style="border:solid 1px sandybrown" :gutter="24">
  <el-col :span="6"><div class="grid-content bg-purple" style=" border-right:solid 1px sandybrown;height: 50px;line-height: 50px">卖家：{{store}}</div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple" style=" border-right:solid 1px sandybrown;height: 50px;line-height: 50px">买家：{{name}}</div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple" style=" border-right:solid 1px sandybrown;height: 50px;line-height: 25px">买家邮箱：{{Email}}</div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple" style=" line-height: 50px">包裹总额：CAD 利润：CNY --</div></el-col>
</el-row>
<div>
<h3>订单状态</h3>
 <div>
        <div class="bzkj" style=" position: relative;
        font-size: 0;
        display: flex;
        justify-content: center;">
        <p style="border: 1px solid sandybrown; height: 1px; width: 900px;position: absolute;top: 9px;z-index: 1;  box-sizing: border-box;"></p>
        <span style="  display: inline-block;
        width: 20px;
        height: 20px;
        font-size: 14px;
        text-align: center;
        background-color: #fff;
        border: 1px rgb(175, 83, 18) solid;
        border-radius: 50%;
        margin: 0 80px 0 80px;
        z-index: 99;" :style=" obj1"></span>
        <span style="  display: inline-block;
        width: 20px;
        height: 20px;
        font-size: 14px;
        text-align: center;
        background-color: #fff;
        border: 1px rgb(175, 83, 18) solid;
        border-radius: 50%;
        margin: 0 80px 0 80px;
        z-index: 99;" :style=" obj2"></span>
        <span style="  display: inline-block;
        width: 20px;
        height: 20px;
        font-size: 14px;
        text-align: center;
        background-color: #fff;
        border: 1px rgb(175, 83, 18) solid;
        border-radius: 50%;
        margin: 0 80px 0 80px;
        z-index: 99;" :style=" obj3"></span>
        <span style="  display: inline-block;
        width: 20px;
        height: 20px;
        font-size: 14px;
        text-align: center;
        background-color: #fff;
        border: 1px rgb(175, 83, 18) solid;
        border-radius: 50%;
        margin: 0 80px 0 80px;
        z-index: 99;"  :style=" obj4"></span>
        <span style="  display: inline-block;
        width: 20px;
        height: 20px;
        font-size: 14px;
        text-align: center;
        background-color: #fff;
        border: 1px rgb(175, 83, 18) solid;
        border-radius: 50%;
        margin: 0 80px 0 80px;
        z-index: 99;"  :style=" obj5"></span>
         <span style="  display: inline-block;
         width: 20px;
         height: 20px;
         font-size: 14px;
         text-align: center;
         background-color: #fff;
         border: 1px rgb(175, 83, 18) solid;
         border-radius: 50%;
         margin: 0 80px 0 80px;
         z-index: 99;"  :style=" obj6"></span>
        </div>
    </div>
    <div style=" display: flex;
        justify-content: center;">
      <span style=" margin: 0 55px 0 90px;  text-align: center;">已审核</span>
      <span style=" margin: 0px 110px 0px 88px;  text-align: center;">已处理</span>
      <span style=" margin: 0px 120px 0px 18px;  text-align: center;">已申请单号</span>
      <span style=" margin: 0px 120px 0px -6px;  text-align: center;">已打拣货单</span>
      <span style=" margin: 0px 115px 0px -4px;  text-align: center;">已打面单</span>
      <span style=" margin: 0px 94px 0px 18px;  text-align: center;">已发货</span>
    </div>
</div>
<div style=" margin-top: 20px">
  <el-tabs :tab-position="tabPosition" style="border:solid 1px sandybrown; ">
    <el-tab-pane label="收货地址">
      <h4 style="text-align: center;border-bottom:solid 1px sandybrown;">收货地址</h4>
      <div style=" font-size: 0;">
        <span 
        style=" display: inline-block;
        width: 50%;
        font-size: 14px;"
        >收件人：{{name}}</span>
        <span style=" display: inline-block;
        width: 50%;
        font-size: 14px;"
        >国家：{{District}}</span>
        <span style=" display: inline-block;
        width: 50%;
        font-size: 14px;"
        >地址：{{AddressLine}}</span>
        <span style=" display: inline-block;
        width: 50%;
        font-size: 14px;"
        >邮编：{{PostalCode}}</span>
        <span style=" display: inline-block;
        width: 50%;
        font-size: 14px;"
        >电话：</span>
        <span style=" display: inline-block;
        width: 50%;
        font-size: 20;"
        >城市：</span>
      </div>
      </el-tab-pane>
    <el-tab-pane label="报关信息"> <h4 style="text-align: center;border-bottom:solid 1px sandybrown;">报关信息</h4>
             <el-table
   :data="tableDataone"
    border
    style="width: 100%">
    <el-table-column
      label="图片"
      width="120">
      <template slot-scope="scope">
        <!-- <div v-for="(index, key) in scope.row.imgs" :key="key">
             <img :src="index"  min-width="70" height="70" />
           </div> -->
           <div>
             <img :src="scope.row.imgs" min-width="70" height="70" >
           </div>
      </template>
    </el-table-column>
    <el-table-column
      prop="name"
      label="标题"
      width="500">
    </el-table-column>
    <el-table-column
      prop="address"
      label="中文报关"
      show-overflow-tooltip>
      <template slot-scope="scope">
        <el-input 
        v-model="scope.row.address"
        placeholder="中文报关" 
        clearable>
        </el-input>
      </template>
    </el-table-column>
     <el-table-column
      prop="address2"
      label="英文报关"
      show-overflow-tooltip>
      <template slot-scope="scope">
          <el-input 
          placeholder="英文报关"
          v-model="scope.row.address2" 
          clearable></el-input>
      </template>
    </el-table-column>
    <el-table-column
      prop="weight"
      label="重量(g)"
      show-overflow-tooltip>
      <template slot-scope="scope">
          <el-input 
          placeholder="重量"
          v-model="scope.row.weight"
          clearable>
          </el-input>
      </template>
    </el-table-column>
    <el-table-column
      prop="USD"
      label="价格(USD)"
      show-overflow-tooltip>
      <template slot-scope="scope">
          <el-input
          placeholder="价格"
           v-model="scope.row.USD" 
           clearable>
           </el-input>
      </template>
    </el-table-column>
    <el-table-column
      prop="customs"
      label="海关编码"
      show-overflow-tooltip>
      <template slot-scope="scope">
          <el-input 
          placeholder="海关编码"
          v-model="scope.row.customs"
           clearable>
           </el-input>
      </template>
    </el-table-column>
    <el-table-column
      label="是否含电"
      width="120">
      <template slot-scope="scope">
           <el-input 
          placeholder="是否"
          v-model="scope.row.label"
           clearable>
           </el-input>
          </template>
    </el-table-column>
  </el-table></el-tab-pane>
    <el-tab-pane label="物流信息"> <h4 style="text-align: center;border-bottom:solid 1px sandybrown;">物流信息</h4>
      <div>
        <div style="line-height: 30px;margin-left:100px; ">买家指定：</div>
        <div style="line-height: 30px;margin-left:100px; ">获取方式：自动获取</div>
        <div style="line-height: 30px;margin-left:100px; ">物流方式：云图物流-福州EUB
          <!-- <el-cascader
            placeholder="请搜索指定物流"
            :options="options"
            filterable
            change-on-select
            ></el-cascader> -->
         </div>
        <div style="line-height: 30px;margin-left:100px; ">预估运费：</div>
      </div></el-tab-pane>
    <el-tab-pane label="备注信息"> <h4 style="text-align: center;border-bottom:solid 1px sandybrown;">备注信息</h4>
      <div >
       <el-table
      :data="table"
      style="width: 100%">
      <el-table-column
        prop="Info"
        label="内容"
        width="500">
      </el-table-column>
      <el-table-column
        prop="update_time"
        label="时间"
        width="250">
      </el-table-column>
      <el-table-column
        prop="username"
        label="操作人"
        width="200">
      </el-table-column>
      <el-table-column
        prop="address"
        label="操作">
         <template scope="scope">
        <el-button type="primary" @click="xgbz(scope.$index)" size="mini">修改备注</el-button>
        </template>
      </el-table-column>
    </el-table>
      </div></el-tab-pane>
  </el-tabs>
</div>
<div style="text-align: right;margin-top:100px; ">
  <el-button @click="dialogTableVisible2 = false"  type="warning" plain>关闭</el-button>
</div>
  </div>
</el-dialog>
<el-dialog title="备注" :visible.sync="dialogFormVisiblebz" :close-on-click-modal="false">
  <el-form :model="form2">
    <el-form-item label="拣货说明">
      <el-input
      type="textarea"
      :rows="2"
      placeholder="请输入内容"
      v-model="form2.date1">
    </el-input>
    </el-form-item>
  </el-form>
  <div slot="footer" class="dialog-footer">
    <el-button @click="dialogFormVisiblebz = false">取 消</el-button>
    <el-button type="primary" @click="refer">确 定</el-button>
  </div>
</el-dialog>
<el-dialog title="修改备注" :visible.sync="dialogFormVisiblebz2" :close-on-click-modal="false">
  <el-form :model="form3">
    <el-form-item label="拣货说明">
      <el-input
      type="textarea"
      :rows="2"
      placeholder="请输入内容"
      v-model="form3.date1">
    </el-input>
    </el-form-item>
  </el-form>
  <div slot="footer" class="dialog-footer">
    <el-button @click="dialogFormVisiblebz2 = false">取 消</el-button>
    <el-button type="primary" @click="refer2">确 定</el-button>
  </div>
</el-dialog>
<div>
      <div style="text-align: right">
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[10]"
      :page-size="10"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
    </div>
  </div>
</template>
<script>
import pagination from "common/pagination";
import axios from "axios";
import html from "../../api/src";

export default {
  inject: ["reload"],
  data() {
    return {
      dpzh : 'all',//店铺账号  默认全部 all
      gj: 'all',//国家筛选  默认全部all、
      ss:'AmazonOrderId_',//搜索类型  默认订单号AmazonOrderId_  
      sortby : 'PurchaseDate',
      channels:['全部','Amazon','其他'],
      pxfs:['下单时间升序','下单时间降序','剩余时间升序','剩余时间降序','订单金额升序','订单金额降序'],
      sslxs:['订单号','包裹号','通过物流跟踪号','通过物流运单号','通过商品的卖家SKU','通过商品编码ASIN','通过卖家姓名'],//搜索类型
      tabPosition: 'left',
      dialogFormVisiblebz:false,//备注开关
      dialogFormVisiblebz2:false,//修改备注开关
      dialogTableVisible: false,//控制更新列表的开关
      dialogTableVisible2:false,//控制订单详情的开关
      a:0,//平台
      b:0,//店铺
      c:0,//国家
      d:0,//排序方式
      e:0,//订单号
       input5: '',//搜索输入框
       select:'',//选中的搜索关键字
      value3: false,//筛选搜索切换开关
      sousuo:true,
       success: [],//存储报关信息
      BuyerName:[],//买家姓名集合
      name:'',//单个买家
      BuyerEmail:[],//买家邮箱集合
      Email:'',//单个买家邮箱
      //详细订单里面的备注信息
       table: [],
       //详细订单里面的报关信息
       Districts:[],//详情订单里面的国家集合
       District:'',//单个详情订单里面的国家
       AddressLines:[],//详情订单地址集合
       AddressLine:'',//单个详情订单地址
       PostalCodes:[],//邮编集合
       PostalCode:'',//单个邮编
       dds:[], //订单id集合
       dd:[], //单个订单id
       gridData:[{
        Info: "fgdgswetwfte",
        update_time: "2019-07-26T14:45:24+08:00",
        username: "xiaobai"
       }],//悬停备注信息
       stores:[],
       store:'',
       tableDataone:[],
      currentPage4: 1,
      total:null,
      a1:true,
      shop:[],
      guojia:['全部','美国','加拿大'],
      // dialogFormVisible: false,
      form: {
        date1: "",
        date2: ""
      },
      // form2是备注的输入内容
       form2: {
        date1: "",
      },
      form3:{
        date1:'',
      },
      all:'all',
      tableData: [],//渲染表单的数据集合
      value: "",
      input2: "",
      DateValue: "",
      close: '同步中',
      percentage: 0,
      customColor: '#409eff',
      timer:null,
      timertwo:null,
      id:null,
      multipleSelection: [],
      arr:null,//同步列表数据
      InfoList: [], // 信息列表
      xyy:[],
      abcd:[],
      str:[],
      str1:[],
      AmazonOrderIds:[],//回滚状态
      bzid:'',//备注事物品id
      xiugaibzid:'',//修改备注id
      indexUrl:'',//存储token
      username:'',//存储名字
        //obj里面颜色说明订单状态 绿色为现在的状态
      Examine:false,
      Deal:false,
      ApplicationOrderNumber:false,
      FaceSheet:false,
      Shipped:false,
      //obj里面颜色说明订单状态 绿色为现在的状态
      obj1:{
        backgroundColor: '#67C23A'
      },
       obj2:{
        backgroundColor: '#67C23A'
      },
       obj3:{
        backgroundColor: '#67C23A'
      },
       obj4:{
        // backgroundColor: '#67C23A'
      },
       obj5:{
        backgroundColor: '#67C23A'
      },
       obj6:{
        // backgroundColor: '#67C23A'
      }
    };
  },
  filters:{
    zt(value){
      if(value == 'Shipped'){
        let a = '发货'
        return a
      }else if(value == 'UnShipped' ){
        let a = '待审核'
        return a
      }else if( value == 'UnDealed' ){
        let a = '待处理'
        return a
      }else if( value == 'UnBilled' ){
        let a = '待发货'
        return a
      }else if( value == 'Canceled'){
        let a = '已取消'
        return a
      }
    },
    flase(value){
      if( value == 'true'){
        let a = '已打单'
        return a
      }else{
        let a = '未打单'
        return a
      }
    }
  },
  created() {
    // 调用请求数据接口
    this.getData();
    this.hqdpxx()
  },
  methods: {
    //点击改变店铺账号值进行渲染
    ptqd(index){
      this.gj = ''
      this.a = index
    },
    sslx(index){
      this.ss = ''
      this.input5 = ''
      this.e = index
      console.log(this.e)
      if(index == 0){
        this.ss = 'AmazonOrderId_'
      }else
      if(index == 1){
        this.ss = 'OrderItemId_'
      }else
      if(index == 2){
        this.ss = 'TrackingNumber_'
      }else
      if(index == 3){
        this.ss = 'WayBillNumber_'
      }else
      if(index == 4){
        this.ss = 'SellerSKU_'
      }else
      if(index == 5){
        this.ss = 'ASIN_'
      }else
      if(index == 6){
        this.ss = 'BuyerName_'
      }
    },
     //刷新页面
     sxym(){
      this.reload();
      that.InfoList = []
      that.tableData = []
      this.getData();
    },
    //搜索按钮
    hunt(){
       axios({
        method: "get",
        url: html.domain +'orders/orderlist/?id='+localStorage.getItem('id')+'&status=UnBilled'+'&countrycode=all'+'&store=all'+'&search='+this.ss+this.input5
      })
      .then(res => {
        let that = this
         that.InfoList = []
          that.tableData = []
          that.BuyerName = []
          that.BuyerEmail= []
          that.Districts = []
          that.AddressLines =[]
          that.PostalCodes = []
          that.dds = []
          that.stores = []
        console.log(res.data)
         that.InfoList = []
          that.tableData = []
        this.total = res.data.count
       this.InfoList = res.data.results
        var str = []; 
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.ASIN); 
                  obj = { 
                      ASIN: Arr 
                  } 
              }); 
                str.push(obj); 
        }
        //  console.log(str); 
        //     for(let i = 0;i<str.length ;i++){
        //     console.log(str[i])
        //     this.tableData.push({
        //       ASIN:str[i]
        //     })
        //     }
         var str1 = [];
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.OrderItemId); 
                  obj = { 
                      OrderItemId: Arr 
                  } 
              }); 
                str1.push(obj); 
        }
        var sku = [];
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.SellerSKU); 
                  obj = { 
                      SellerSKU: Arr 
                  } 
              }); 
          sku.push(obj); 
        }
        let imgs1 = [];
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.GoodsImage); 
                  obj = { 
                      GoodsImage: Arr 
                  } 
              }); 
          imgs1.push(obj); 
        }
 
        for(let i = 0;i<that.InfoList.length ;i++){
          if(that.InfoList[i].BuyerName  == ""){
            that.InfoList[i].BuyerName = '无'
          }
          if(that.InfoList[i].ShippingAddress == null){
             that.InfoList[i].ShippingAddress = {
              CountryCode: '/'
              }
          }
          if(that.InfoList[i].OrderTotal == null){
              console.log(2)
              that.InfoList[i].OrderTotal = {
              Amount: '/'
              }
            }
            this.gridData = this.InfoList[i].infos_set
            console.log(this.gridData)
          this.tableData.push({
          OrderItemId:str1[i],
          ASIN:str[i],
          SellerSKU:sku[i],
          imgs:imgs1[i],
          ting:this.InfoList[i].infos_set.length,
          day_flow: that.InfoList[i].OrderStatus,
          // BuyerName: that.InfoList[i].BuyerName,
          Amounttwo: that.InfoList[i].OrderTotal.Amount,
          District: that.InfoList[i].ShippingAddress.CountryCode,
          dTrackingNumdh:that.InfoList[i].TrackingNumber,
          USD: that.InfoList[i].OrderTotal.CurrencyCode,
          AmazonOrderId:that.InfoList[i].AmazonOrderId,
          day_up_goods:`标准/平邮
             配送日期：${that.InfoList[i].EarliestShipDate.substring(0,10)}至${that.InfoList[i].LatestShipDate.substring(0,10)}
             送达日期：${that.InfoList[i].EarliestDeliveryDate.substring(0,10)}至${that.InfoList[i].LatestDeliveryDate.substring(0,10)}`
        })
         console.log(this.tableData)
         that.BuyerName.push(that.InfoList[i].BuyerName)
          that.BuyerEmail.push(that.InfoList[i].BuyerEmail)
          that.Districts.push(that.InfoList[i].ShippingAddress.CountryCode)
          that.AddressLines.push(that.InfoList[i].ShippingAddress.AddressLine1)
          that.PostalCodes.push(that.InfoList[i].ShippingAddress.PostalCode)
          that.dds.push(str1[i])
          that.stores.push(that.InfoList[i].SellerStore.store)
        }
        console.log(that.dds)
          
      //       success: [],//存储报关信息
      // BuyerName:[],//买家姓名集合
      // name:'',//单个买家
      // BuyerEmail:[],//买家邮箱集合
      // Email:'',//单个买家邮箱
      // //详细订单里面的备注信息
      //  table: [],
      //  //详细订单里面的报关信息
      //  Districts:[],//详情订单里面的国家集合
      //  District:'',//单个详情订单里面的国家
      //  AddressLines:[],//详情订单地址集合
      //  AddressLine:'',//单个详情订单地址
      //  PostalCodes:[],//邮编集合
      //  PostalCode:'',//单个邮编
      //  dds:[], //订单id集合
      //  dd:[], //单个订单id
        console.log(this.tableData) 
      });
    },
    //国家区域
    gjqy(index){
      let that = this
      this.c = index
      if(index == 0){
        this.gj = 'all'
      }else
      if(index == 1){
        this.gj = 'US'
      }else
      if(index == 2){
        this.gj = 'CA'
      }
      console.log(this.gj)
       axios({
        method: "get",
        url: html.domain +'orders/orderlist/?id='+localStorage.getItem('id')+'&status=UnBilled'+'&countrycode='+this.gj+'&store='+this.dpzh
      })
      .then(res => {
         that.InfoList = []
          that.tableData = []
           that.InfoList = []
          that.tableData = []
          that.BuyerName = []
          that.BuyerEmail= []
          that.Districts = []
          that.AddressLines =[]
          that.PostalCodes = []
          that.dds = []
          that.stores = []
        this.total = res.data.count
       this.InfoList = res.data.results
      console.log(res.data)
        var str = []; 
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.ASIN); 
                  obj = { 
                      ASIN: Arr 
                  } 
              }); 
                str.push(obj); 
        }
        //  console.log(str); 
        //     for(let i = 0;i<str.length ;i++){
        //     console.log(str[i])
        //     this.tableData.push({
        //       ASIN:str[i]
        //     })
        //     }
         var str1 = [];
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.OrderItemId); 
                  obj = { 
                      OrderItemId: Arr 
                  } 
              }); 
                str1.push(obj); 
        }
        var sku = [];
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.SellerSKU); 
                  obj = { 
                      SellerSKU: Arr 
                  } 
              }); 
          sku.push(obj); 
        }
        let imgs1 = [];
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.GoodsImage); 
                  obj = { 
                      GoodsImage: Arr 
                  } 
              }); 
          imgs1.push(obj); 
        }
 
        for(let i = 0;i<that.InfoList.length ;i++){
          if(that.InfoList[i].BuyerName  == ""){
            that.InfoList[i].BuyerName = '无'
          }
          if(that.InfoList[i].ShippingAddress == null){
             that.InfoList[i].ShippingAddress = {
              CountryCode: '/'
              }
          }
          if(that.InfoList[i].OrderTotal == null){
              console.log(2)
              that.InfoList[i].OrderTotal = {
              Amount: '/'
              }
            }
            this.gridData = this.InfoList[i].infos_set
            console.log(this.gridData)
          this.tableData.push({
          OrderItemId:str1[i],
          ASIN:str[i],
          SellerSKU:sku[i],
          ting:this.InfoList[i].infos_set.length,
          imgs:imgs1[i],
          day_flow: that.InfoList[i].OrderStatus,
           dTrackingNumdh:that.InfoList[i].TrackingNumber,
          // BuyerName: that.InfoList[i].BuyerName,
          Amounttwo: that.InfoList[i].OrderTotal.Amount,
          District: that.InfoList[i].ShippingAddress.CountryCode,
          USD: that.InfoList[i].OrderTotal.CurrencyCode,
          AmazonOrderId:that.InfoList[i].AmazonOrderId,
          day_up_goods:`标准/平邮
             配送日期：${that.InfoList[i].EarliestShipDate.substring(0,10)}至${that.InfoList[i].LatestShipDate.substring(0,10)}
             送达日期：${that.InfoList[i].EarliestDeliveryDate.substring(0,10)}至${that.InfoList[i].LatestDeliveryDate.substring(0,10)}`
        })
         that.BuyerName.push(that.InfoList[i].BuyerName)
          that.BuyerEmail.push(that.InfoList[i].BuyerEmail)
          that.Districts.push(that.InfoList[i].ShippingAddress.CountryCode)
          that.AddressLines.push(that.InfoList[i].ShippingAddress.AddressLine1)
          that.PostalCodes.push(that.InfoList[i].ShippingAddress.PostalCode)
          that.dds.push(str1[i])
          that.stores.push(that.InfoList[i].SellerStore.store)
        }
      });
    },
    //排序方式
    pxff(index){
      console.log(index)
      this.d = index
       if(index == 0){
        this.sortby = 'PurchaseDate '
      }else
      if(index == 1){
        this.sortby = '-PurchaseDate'
      }else
      if(index == 2){
        this.sortby = 'LatestShipDate'
      }else
      if(index == 3){
        this.sortby = '-LatestShipDate'
      }else
      if(index == 4){
        this.sortby = 'OrderTotal__Amount'
      }else
      if(index == 5){
        this.sortby = '-OrderTotal__Amount'
      }
      console.log(this.sortby)
       axios({
        method: "get",
        url: html.domain +'orders/orderlist/?id='+localStorage.getItem('id')+'&status=UnBilled'+'&countrycode='+this.gj+'&store='+this.dpzh+'&sortby='+this.sortby
      })
      .then(res => {
        let that = this
        console.log(res.data)
         that.InfoList = []
          that.tableData = []
           that.InfoList = []
          that.tableData = []
          that.BuyerName = []
          that.BuyerEmail= []
          that.Districts = []
          that.AddressLines =[]
          that.PostalCodes = []
          that.dds = []
          that.stores = []
        this.total = res.data.count
       this.InfoList = res.data.results
        var str = []; 
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.ASIN); 
                  obj = { 
                      ASIN: Arr 
                  } 
              }); 
                str.push(obj); 
        }
        //  console.log(str); 
        //     for(let i = 0;i<str.length ;i++){
        //     console.log(str[i])
        //     this.tableData.push({
        //       ASIN:str[i]
        //     })
        //     }
         var str1 = [];
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.OrderItemId); 
                  obj = { 
                      OrderItemId: Arr 
                  } 
              }); 
                str1.push(obj); 
        }
        var sku = [];
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.SellerSKU); 
                  obj = { 
                      SellerSKU: Arr 
                  } 
              }); 
          sku.push(obj); 
        }
        let imgs1 = [];
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.GoodsImage); 
                  obj = { 
                      GoodsImage: Arr 
                  } 
              }); 
          imgs1.push(obj); 
        }
 
        for(let i = 0;i<that.InfoList.length ;i++){
          if(that.InfoList[i].BuyerName  == ""){
            that.InfoList[i].BuyerName = '无'
          }
          if(that.InfoList[i].ShippingAddress == null){
             that.InfoList[i].ShippingAddress = {
              CountryCode: '/'
              }
          }
          if(that.InfoList[i].OrderTotal == null){
              console.log(2)
              that.InfoList[i].OrderTotal = {
              Amount: '/'
              }
            }
            this.gridData = this.InfoList[i].infos_set
            console.log(this.gridData)
          this.tableData.push({
          OrderItemId:str1[i],
          ASIN:str[i],
          ting:this.InfoList[i].infos_set.length,
          SellerSKU:sku[i],
          imgs:imgs1[i],
          day_flow: that.InfoList[i].OrderStatus,
          // BuyerName: that.InfoList[i].BuyerName,
          Amounttwo: that.InfoList[i].OrderTotal.Amount,
          District: that.InfoList[i].ShippingAddress.CountryCode,
           dTrackingNumdh:that.InfoList[i].TrackingNumber,
          USD: that.InfoList[i].OrderTotal.CurrencyCode,
          AmazonOrderId:that.InfoList[i].AmazonOrderId,
          day_up_goods:`标准/平邮
             配送日期：${that.InfoList[i].EarliestShipDate.substring(0,10)}至${that.InfoList[i].LatestShipDate.substring(0,10)}
             送达日期：${that.InfoList[i].EarliestDeliveryDate.substring(0,10)}至${that.InfoList[i].LatestDeliveryDate.substring(0,10)}`
        })
         console.log(this.tableData)
         that.BuyerName.push(that.InfoList[i].BuyerName)
          that.BuyerEmail.push(that.InfoList[i].BuyerEmail)
          that.Districts.push(that.InfoList[i].ShippingAddress.CountryCode)
          that.AddressLines.push(that.InfoList[i].ShippingAddress.AddressLine1)
          that.PostalCodes.push(that.InfoList[i].ShippingAddress.PostalCode)
          that.dds.push(str1[i])
          that.stores.push(that.InfoList[i].SellerStore.store)
        }
        console.log(that.dds)
          
      //       success: [],//存储报关信息
      // BuyerName:[],//买家姓名集合
      // name:'',//单个买家
      // BuyerEmail:[],//买家邮箱集合
      // Email:'',//单个买家邮箱
      // //详细订单里面的备注信息
      //  table: [],
      //  //详细订单里面的报关信息
      //  Districts:[],//详情订单里面的国家集合
      //  District:'',//单个详情订单里面的国家
      //  AddressLines:[],//详情订单地址集合
      //  AddressLine:'',//单个详情订单地址
      //  PostalCodes:[],//邮编集合
      //  PostalCode:'',//单个邮编
      //  dds:[], //订单id集合
      //  dd:[], //单个订单id
        console.log(this.tableData) 
      });
    },
    //店铺账号
    dpzhs(index){
      this.b = index
      this.dpzh = ''
      this.dpzh = this.shop[index]
      if(this.dpzh == '全部'){
        this.dpzh = 'all'
      }
      console.log(this.dpzh)
     axios({
        method: "get",
        url: html.domain +'orders/orderlist/?id='+localStorage.getItem('id')+'&status=UnBilled'+'&countrycode='+this.all+'&store='+this.dpzh
      })
      .then(res => {
        let that = this
         that.InfoList = []
          that.tableData = []
           that.InfoList = []
          that.tableData = []
          that.BuyerName = []
          that.BuyerEmail= []
          that.Districts = []
          that.AddressLines =[]
          that.PostalCodes = []
          that.dds = []
          that.stores = []
        this.total = res.data.count
       this.InfoList = res.data.results
      console.log(res.data)
        var str = []; 
       
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.ASIN); 
                  obj = { 
                      ASIN: Arr 
                  } 
              }); 
                str.push(obj); 
        }
        //  console.log(str); 
        //     for(let i = 0;i<str.length ;i++){
        //     console.log(str[i])
        //     this.tableData.push({
        //       ASIN:str[i]
        //     })
        //     }
         var str1 = [];
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.OrderItemId); 
                  obj = { 
                      OrderItemId: Arr 
                  } 
              }); 
                str1.push(obj); 
        }
        var sku = [];
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.SellerSKU); 
                  obj = { 
                      SellerSKU: Arr 
                  } 
              }); 
          sku.push(obj); 
        }
        let imgs1 = [];
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.GoodsImage); 
                  obj = { 
                      GoodsImage: Arr 
                  } 
              }); 
          imgs1.push(obj); 
        }
 
        for(let i = 0;i<that.InfoList.length ;i++){
          if(that.InfoList[i].BuyerName  == ""){
            that.InfoList[i].BuyerName = '无'
          }
          if(that.InfoList[i].ShippingAddress == null){
             that.InfoList[i].ShippingAddress = {
              CountryCode: '/'
              }
          }
          if(that.InfoList[i].OrderTotal == null){
              console.log(2)
              that.InfoList[i].OrderTotal = {
              Amount: '/'
              }
            }
            this.gridData = this.InfoList[i].infos_set
            console.log(this.gridData)
          this.tableData.push({
          OrderItemId:str1[i],
          ASIN:str[i],
          SellerSKU:sku[i],
          imgs:imgs1[i],
          day_flow: that.InfoList[i].OrderStatus,
          ting:this.InfoList[i].infos_set.length,
           dTrackingNumdh:that.InfoList[i].TrackingNumber,
          // BuyerName: that.InfoList[i].BuyerName,
          Amounttwo: that.InfoList[i].OrderTotal.Amount,
          District: that.InfoList[i].ShippingAddress.CountryCode,
          USD: that.InfoList[i].OrderTotal.CurrencyCode,
          AmazonOrderId:that.InfoList[i].AmazonOrderId,
          day_up_goods:`标准/平邮
             配送日期：${that.InfoList[i].EarliestShipDate.substring(0,10)}至${that.InfoList[i].LatestShipDate.substring(0,10)}
             送达日期：${that.InfoList[i].EarliestDeliveryDate.substring(0,10)}至${that.InfoList[i].LatestDeliveryDate.substring(0,10)}`
        })
         that.BuyerName.push(that.InfoList[i].BuyerName)
          that.BuyerEmail.push(that.InfoList[i].BuyerEmail)
          that.Districts.push(that.InfoList[i].ShippingAddress.CountryCode)
          that.AddressLines.push(that.InfoList[i].ShippingAddress.AddressLine1)
          that.PostalCodes.push(that.InfoList[i].ShippingAddress.PostalCode)
          that.dds.push(str1[i])
          that.stores.push(that.InfoList[i].SellerStore.store)
        }
        console.log(that.dds)
          
      //       success: [],//存储报关信息
      // BuyerName:[],//买家姓名集合
      // name:'',//单个买家
      // BuyerEmail:[],//买家邮箱集合
      // Email:'',//单个买家邮箱
      // //详细订单里面的备注信息
      //  table: [],
      //  //详细订单里面的报关信息
      //  Districts:[],//详情订单里面的国家集合
      //  District:'',//单个详情订单里面的国家
      //  AddressLines:[],//详情订单地址集合
      //  AddressLine:'',//单个详情订单地址
      //  PostalCodes:[],//邮编集合
      //  PostalCode:'',//单个邮编
      //  dds:[], //订单id集合
      //  dd:[], //单个订单id
        console.log(this.tableData) 
      });
    },
     //提交备注
    refer(){
      axios({
         method: "post",
           url: html.domain + "orders/updateinfo/",
           data:{
              Order: this.bzid,
              username:localStorage.getItem('username'),
              Info: this.form2.date1
           },
           headers:{
            "Authorization": localStorage.getItem('indexUrl')  //请求头携带的token
        }
        })
        .then(res =>{
            this.$message({
            type: "success",
            message: res.data.success_msg
          });
          this.dialogFormVisiblebz = false
          this.reload()
        })
      
      // console.log(this.bzid)
    },
    refer2(){
        axios({
         method: "post",
           url: html.domain + "orders/updateinfo/",
           data:{
              Order: this.bzid,
              id: this.xiugaibzid,
              username:localStorage.getItem('username'),
              Info: this.form3.date1
           },
           headers:{
            "Authorization": localStorage.getItem('indexUrl')  //请求头携带的token
        }
        })
        .then(res =>{
          console.log(res)
            this.$message({
            type: "success",
            message: res.data.success_msg
          });
          this.dialogFormVisiblebz = false
          this.reload()
        })
    },
    //备注
    bz(index){
      this.dialogFormVisiblebz = true
      this.bzid = this.InfoList[index].id
      console.log(this.bzid)
    },
    //修改备注 
    xgbz(index){
      console.log(this.bzid)
      this.xiugaibzid = this.table[index].id
      console.log(this.xiugaibzid)
       this.dialogFormVisiblebz2 = true
    }, 
       // 分页
    //  handleSizeChange(val) {
    //     console.log( val);
    //   },
      handleCurrentChange(val) {
        let that = this
        console.log(val);
        axios({
           method: "get",
           url: html.domain + "orders/orderlist/?id="+localStorage.getItem('id')+'&status=UnBilled'+'&countrycode='+this.gj+'&store=all'+'&sortby='+this.sortby+"&page="+val,
           headers:{
            "Authorization": localStorage.getItem('indexUrl')  //请求头携带的token
        }
        })
        .then(res => {
          that.InfoList = []
          that.tableData = []
           that.InfoList = []
          that.tableData = []
          that.BuyerName = []
          that.BuyerEmail= []
          that.Districts = []
          that.AddressLines =[]
          that.PostalCodes = []
          that.dds = []
          that.stores = []
       this.InfoList = res.data.results
      console.log(res.data)
        var str = []; 
       
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.ASIN); 
                  obj = { 
                      ASIN: Arr 
                  } 
              }); 
                str.push(obj); 
        }
        //  console.log(str); 
        //     for(let i = 0;i<str.length ;i++){
        //     console.log(str[i])
        //     this.tableData.push({
        //       ASIN:str[i]
        //     })
        //     }
         var str1 = [];
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.OrderItemId); 
                  obj = { 
                      OrderItemId: Arr 
                  } 
              }); 
                str1.push(obj); 
        }
        var sku = [];
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.SellerSKU); 
                  obj = { 
                      SellerSKU: Arr 
                  } 
              }); 
          sku.push(obj); 
        }
        let imgs1 = [];
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.GoodsImage); 
                  obj = { 
                      GoodsImage: Arr 
                  } 
              }); 
          imgs1.push(obj); 
        }
 
        for(let i = 0;i<that.InfoList.length ;i++){
          if(that.InfoList[i].BuyerName  == ""){
            that.InfoList[i].BuyerName = '无'
          }
          if(that.InfoList[i].ShippingAddress == null){
             that.InfoList[i].ShippingAddress = {
              CountryCode: '/'
              }
          }
          if(that.InfoList[i].OrderTotal == null){
              console.log(2)
              that.InfoList[i].OrderTotal = {
              Amount: '/'
              }
            }
        this.tableData.push({
          OrderItemId:str1[i],
          ASIN:str[i],
          SellerSKU:sku[i],
          ting:this.InfoList[i].infos_set.length,
          imgs:imgs1[i],
          day_flow: that.InfoList[i].OrderStatus,
           dTrackingNumdh:that.InfoList[i].TrackingNumber,
          // BuyerName: that.InfoList[i].BuyerName,
          Amounttwo: that.InfoList[i].OrderTotal.Amount,
          USD: that.InfoList[i].OrderTotal.CurrencyCode,
          District: that.InfoList[i].ShippingAddress.CountryCode,
          AmazonOrderId:that.InfoList[i].AmazonOrderId,
          day_up_goods:`标准/平邮
             配送日期：${that.InfoList[i].EarliestShipDate.substring(0,10)}至${that.InfoList[i].LatestShipDate.substring(0,10)}
             送达日期：${that.InfoList[i].EarliestDeliveryDate.substring(0,10)}至${that.InfoList[i].LatestDeliveryDate.substring(0,10)}`
        })
          that.BuyerName.push(that.InfoList[i].BuyerName)
          that.BuyerEmail.push(that.InfoList[i].BuyerEmail)
          that.Districts.push(that.InfoList[i].ShippingAddress.CountryCode)
          that.AddressLines.push(that.InfoList[i].ShippingAddress.AddressLine1)
          that.PostalCodes.push(that.InfoList[i].ShippingAddress.PostalCode)
          that.dds.push(str1[i])
          that.stores.push(that.InfoList[i].SellerStore.store)
        }
        console.log(this.tableData) 
      });
      },
    changeFun (val) {
      this.multipleSelection = val // 返回的是选中的列的数组集合
      console.log( this.multipleSelection )
      },
    // 请求数据接口
      getData() {
      let that = this;
      axios({
        method: "get",
        url: html.domain +'orders/orderlist/?id='+localStorage.getItem('id')+'&status=UnBilled'+'&countrycode='+this.all+'&store='+this.dpzh
      })
      .then(res => {
        this.total = res.data.count
       this.InfoList = res.data.results
      console.log(res.data)
        var str = []; 
       
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.ASIN); 
                  obj = { 
                      ASIN: Arr 
                  } 
              }); 
                str.push(obj); 
        }
        //  console.log(str); 
        //     for(let i = 0;i<str.length ;i++){
        //     console.log(str[i])
        //     this.tableData.push({
        //       ASIN:str[i]
        //     })
        //     }
         var str1 = [];
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.OrderItemId); 
                  obj = { 
                      OrderItemId: Arr 
                  } 
              }); 
                str1.push(obj); 
        }
        var sku = [];
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.SellerSKU); 
                  obj = { 
                      SellerSKU: Arr 
                  } 
              }); 
          sku.push(obj); 
        }
        let imgs1 = [];
        for (let i = 0; i < this.InfoList.length; i++) { 
              let obj = {}; 
              let Arr = []; 
              // if( this.InfoList[i].orderitem_set == ""){
              //     this.InfoList[i].orderitem_set
              // }
              this.InfoList[i].orderitem_set.forEach((v) => { 
                  Arr.push(v.GoodsImage); 
                  obj = { 
                      GoodsImage: Arr 
                  } 
              }); 
          imgs1.push(obj); 
        }
 
        for(let i = 0;i<that.InfoList.length ;i++){
          if(that.InfoList[i].BuyerName  == ""){
            that.InfoList[i].BuyerName = '无'
          }
          if(that.InfoList[i].ShippingAddress == null){
             that.InfoList[i].ShippingAddress = {
              CountryCode: '/'
              }
          }
          if(that.InfoList[i].OrderTotal == null){
              console.log(2)
              that.InfoList[i].OrderTotal = {
              Amount: '/'
              }
            }
          if(that.InfoList[i].FaceSheet == true){
              that.InfoList[i].FaceSheet = 'true'
          }else{
            that.InfoList[i].FaceSheet = 'false'
          }
            this.gridData = this.InfoList[i].infos_set
            console.log(that.InfoList[i].FaceSheet)
          this.tableData.push({
          OrderItemId:str1[i],
          ting:this.InfoList[i].infos_set.length,
          ASIN:str[i],
          SellerSKU:sku[i],
          imgs:imgs1[i],
          FaceSheet: that.InfoList[i].FaceSheet,
          day_flow: that.InfoList[i].OrderStatus,
           dTrackingNumdh:that.InfoList[i].TrackingNumber,
          // BuyerName: that.InfoList[i].BuyerName,
          Amounttwo: that.InfoList[i].OrderTotal.Amount,
          USD: that.InfoList[i].OrderTotal.CurrencyCode,
          District: that.InfoList[i].ShippingAddress.CountryCode,
          AmazonOrderId:that.InfoList[i].AmazonOrderId,
          day_up_goods:`标准/平邮
             配送日期：${that.InfoList[i].EarliestShipDate.substring(0,10)}至${that.InfoList[i].LatestShipDate.substring(0,10)}
             送达日期：${that.InfoList[i].EarliestDeliveryDate.substring(0,10)}至${that.InfoList[i].LatestDeliveryDate.substring(0,10)}`
        })
         that.BuyerName.push(that.InfoList[i].BuyerName)
          that.BuyerEmail.push(that.InfoList[i].BuyerEmail)
          that.Districts.push(that.InfoList[i].ShippingAddress.CountryCode)
          that.AddressLines.push(that.InfoList[i].ShippingAddress.AddressLine1)
          that.PostalCodes.push(that.InfoList[i].ShippingAddress.PostalCode)
          that.dds.push(str1[i])
          that.stores.push(that.InfoList[i].SellerStore.store)
        }
        console.log(that.tableData.FaceSheet)
          
      //       success: [],//存储报关信息
      // BuyerName:[],//买家姓名集合
      // name:'',//单个买家
      // BuyerEmail:[],//买家邮箱集合
      // Email:'',//单个买家邮箱
      // //详细订单里面的备注信息
      //  table: [],
      //  //详细订单里面的报关信息
      //  Districts:[],//详情订单里面的国家集合
      //  District:'',//单个详情订单里面的国家
      //  AddressLines:[],//详情订单地址集合
      //  AddressLine:'',//单个详情订单地址
      //  PostalCodes:[],//邮编集合
      //  PostalCode:'',//单个邮编
      //  dds:[], //订单id集合
      //  dd:[], //单个订单id
        console.log(this.tableData) 
      });
    },
    receivePageSize(val) {
      console.log(val);
    },
    receiveCurrentPage(val) {
      console.log(val);
    },
    
    // 修改table header的背景色
    tableHeaderColor({ row, column, rowIndex, columnIndex }) {
      if (rowIndex === 0) {
        return "background-color: #F7F6Fd;color: #B6B5C2;font-weight: 500;";
      }
    },
    // 删除
    ondelete() {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!"
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },
    // 跳转到详情页面
    details(index){
       this.Examine = this.InfoList[index].Examine
       this.bzid = this.InfoList[index].id
       if(this.Examine == true){
        this.obj1.backgroundColor = '#67C23A'
       }else{
        this.obj1.backgroundColor = '#F2F6FC'
       }
       this.Deal = this.InfoList[index].Deal
        if(this.Deal == true){
        this.obj2.backgroundColor = '#67C23A'
       }else{
        this.obj2.backgroundColor = '#F2F6FC'
       }
       this.ApplicationOrderNumber = this.InfoList[index].ApplicationOrderNumber
         if(this.ApplicationOrderNumber == true){
        this.obj3.backgroundColor = '#67C23A'
       }else{
        this.obj3.backgroundColor = '#F2F6FC'
       }
       this.FaceSheet = this.InfoList[index].FaceSheet
         if(this.FaceSheet == 'true'){
        this.obj5.backgroundColor = '#67C23A'
       }else{
        this.obj5.backgroundColor = '#F2F6FC'
       }
       this.Shipped = this.InfoList[index].Shipped
         if(this.Shipped == true){
        this.obj6.backgroundColor = '#67C23A'
       }else{
        this.obj6.backgroundColor = '#F2F6FC'
       }
      console.log(this.dds[index].OrderItemId[0])
      this.table = this.InfoList[index].infos_set
            this.dd = []
      this.tableDataone = []
      this.dialogTableVisible2 = true
      this.name = this.BuyerName[index]
      this.Email = this.BuyerEmail[index]
      this.District = this.Districts[index] 
      this.AddressLine = this.AddressLines[index]
      this.PostalCode = this.PostalCodes[index]
      this.store = this.stores[index]
      this.dd = this.dds[index].OrderItemId
      axios({
           method: "post",
           url: html.domain + "orders/getcustomsdeclist/",
           data: this.dd,
           headers:{
            "Authorization": localStorage.getItem('indexUrl')  //请求头携带的token
        }
        })
        .then(res => {
          let that = this
          that.success = res.data.success_msg
          console.log(res)
             for(let i =0 ; i<that.success.length;i++){
               if(that.success[i].CustomsDeclarationInfo == null){
                that.success[i].CustomsDeclarationInfo = {
                  address:'',
                  address2:'',
                  weight:'',
                  USD:'',
                  customs:'',
                  label:'',
                }
               }
              that.tableDataone.push({
          //console.log(this.tableData[0].address)
          // console.log(this.tableData[0].address2)
          // console.log(this.tableData[0].weight)
          // console.log(this.tableData[0].USD)
          // console.log(this.tableData[0].customs)
          // console.log(this.tableData[0].label)
              imgs : that.success[i].GoodsImage,
              name: that.success[i].Title,
              address:that.success[i].CustomsDeclarationInfo.ChineseCustomsDeclaration,
              address2:that.success[i].CustomsDeclarationInfo.EnglishCustomsDeclaration,
              weight:that.success[i].CustomsDeclarationInfo.Weight,
              USD:that.success[i].CustomsDeclarationInfo.Price,
              customs:that.success[i].CustomsDeclarationInfo.CustomsCode,
              label:that.success[i].CustomsDeclarationInfo.IsElectric,
              
              })
              console.log(that.success)
          }
        })
      // console.log(1)
      // this.$router.push({path:"/menu2/sub2",query: {id:'1'}})
    },
    // 进度条
    increase() {
      this.percentage += 10;
      if(this.percentage > 100){
        this.percentage = 100
      }
    },
    // 订单请求
    updata(){
      this.dialogTableVisible = true;
      let that = this;
      axios({
         method: "get",
         url: html.domain + "orders/orderupdate/",
         headers:{
            "Authorization": localStorage.getItem('indexUrl')  //请求头携带的token
        }
      })
      .then(res => {
        console.log(res.data)
        this.close = '';
        this.close = '已完成'
        this.percentage = 100 
      })
      this.timertwo = setInterval(()=>{
        axios({
         method: "get",
         url: html.domain + "orders/getupdatelist/",
         headers:{
            "Authorization": localStorage.getItem('indexUrl')  //请求头携带的token
        }
        })
        .then(res => {
          this.percentage += 2
          console.log(res.data)
          that.arr = res.data.success_msg.update_list;
          console.log(res.data.success_msg.update_status)
           if(res.data.success_msg.update_status == '更新完毕'){
            console.log(132);
            that.abc();
          }
        })
       },2000)
      //  setInterval(()=>{
      //     clearInterval(timertwo);
      //  },10000)
      //  if( that.close == '已完成'){
      //     clearInterval(timertwo);
      //     that.timertwo = null;
      //  }
       console.log(that.close)
    },
    a(){
      console.log(1)
    },
    abc(){

      clearInterval(this.timertwo)
      console.log("清除定时器")
    },
    // 点击订单商品  index表格索引  index2 对应数组索引
     OrderItemId(index,index2){
        this.Examine = this.InfoList[index].Examine
        this.bzid = this.InfoList[index].id
       if(this.Examine == true){
        this.obj1.backgroundColor = '#67C23A'
       }else{
        this.obj1.backgroundColor = '#F2F6FC'
       }
       this.Deal = this.InfoList[index].Deal
        if(this.Deal == true){
        this.obj2.backgroundColor = '#67C23A'
       }else{
        this.obj2.backgroundColor = '#F2F6FC'
       }
       this.ApplicationOrderNumber = this.InfoList[index].ApplicationOrderNumber
         if(this.ApplicationOrderNumber == true){
        this.obj3.backgroundColor = '#67C23A'
       }else{
        this.obj3.backgroundColor = '#F2F6FC'
       }
       this.FaceSheet = this.InfoList[index].FaceSheet
         if(this.FaceSheet == 'true'){
        this.obj5.backgroundColor = '#67C23A'
       }else{
        this.obj5.backgroundColor = '#F2F6FC'
       }
       this.Shipped = this.InfoList[index].Shipped
         if(this.Shipped == true){
        this.obj6.backgroundColor = '#67C23A'
       }else{
        this.obj6.backgroundColor = '#F2F6FC'
       }
       console.log(this.dds)
       this.table = this.InfoList[index].infos_set
      this.dd = []
      this.tableDataone = []
      this.dialogTableVisible2 = true
      this.name = this.BuyerName[index]
      this.Email = this.BuyerEmail[index]
      this.District = this.Districts[index] 
      this.AddressLine = this.AddressLines[index]
      this.PostalCode = this.PostalCodes[index]
      this.store = this.stores[index]
      this.dd = this.dds[index].OrderItemId
    
      axios({
           method: "post",
           url: html.domain + "orders/getcustomsdeclist/",
           data: this.dd,
           headers:{
            "Authorization": localStorage.getItem('indexUrl')  //请求头携带的token
        }
        })
        .then(res => {
          let that = this
          that.success = res.data.success_msg
          console.log(res)
             for(let i =0 ; i<that.success.length;i++){
               if(that.success[i].CustomsDeclarationInfo == null){
                that.success[i].CustomsDeclarationInfo = {
                  address:'',
                  address2:'',
                  weight:'',
                  USD:'',
                  customs:'',
                  label:'',
                }
               }
              that.tableDataone.push({
          //console.log(this.tableData[0].address)
          // console.log(this.tableData[0].address2)
          // console.log(this.tableData[0].weight)
          // console.log(this.tableData[0].USD)
          // console.log(this.tableData[0].customs)
          // console.log(this.tableData[0].label)
              imgs : that.success[i].GoodsImage,
              name: that.success[i].Title,
              address:that.success[i].CustomsDeclarationInfo.ChineseCustomsDeclaration,
              address2:that.success[i].CustomsDeclarationInfo.EnglishCustomsDeclaration,
              weight:that.success[i].CustomsDeclarationInfo.Weight,
              USD:that.success[i].CustomsDeclarationInfo.Price,
              customs:that.success[i].CustomsDeclarationInfo.CustomsCode,
              label:that.success[i].CustomsDeclarationInfo.IsElectric,
              
              })
              console.log(that.success)
          }
        })
            //  console.log(index)
      //  console.log(index2)
      //  console.log(this.tableData)
      //  console.log(this.tableData[index].AmazonOrderId)
      // alert(this.tableData[index].OrderItemId[index2])
      //  console.log(this.tableData[index].OrderItemId[index2])
    },

    sx(){
      // this.$router.go(0)
      this.reload();
    },
  hqdpxx(){
    axios({
       method: "get",
       url: html.domain + "store/storenamelist/?id="+localStorage.getItem('id'),
       headers:{
            "Authorization": localStorage.getItem('indexUrl')  //请求头携带的token
        }
        })
        .then(res => {
          this.shop = ['全部',...res.data.success_msg]
          console.log(res)
    })
  },
  changeFun (val) {
      this.multipleSelection = val // 返回的是选中的列的数组集合
      console.log( this.multipleSelection )
      },
       //打印面单
    goprint(){
      console.log
         this.str = [];
      for(let i = 0; i<this.multipleSelection.length;i++){
        // console.log(this.multipleSelection[i].AmazonOrderId)
        this.str.push(this.multipleSelection[i].dTrackingNumdh)
      }
      
      console.log(this.str)
      axios({
        method: "post",
          url: html.domain + "orders/labelprint/",
          data: this.str,
          headers:{
            "Authorization": localStorage.getItem('indexUrl')  //请求头携带的token
        }
      })
      .then(res =>{
        console.log(res.data)
        window.open(res.data);
      })
    },
    // 单点发货
    gofahuo(index){
    console.log(index)
     console.log( this.tableData[index].AmazonOrderId)
     axios({
         method: "post",
        url: html.domain + "orders/updateorderstatus/",
        data:{
          AmazonOrderId: [this.tableData[index].AmazonOrderId],
          OrderStatus: 'Shipped',
        }
     })
     .then(res => {
       this.reload();
       console.log(res)
     })
    },
    //单点打印面单
    goexpress(index){
      this.str1 = [];
      this.str1.push(this.tableData[index].dTrackingNumdh)
      console.log(this.tableData[index].dTrackingNumdh)
        axios({
        method: "post",
          url: html.domain + "orders/labelprint/",
          data: this.str1,
           headers:{
            "Authorization": localStorage.getItem('indexUrl')  //请求头携带的token
        }
      })
      .then(res =>{
        console.log(res.data)
        window.open(res.data);
        this.reload();
      })
    },
    //批量发货
      goShipped(){
          for(let i = 0 ; i<this.multipleSelection.length; i++){
      this.AmazonOrderIds.push(this.multipleSelection[i].AmazonOrderId)
      console.log( this.AmazonOrderIds )
      }
        axios({
        method: "post",
        url: html.domain + "orders/updateorderstatus/",
        data:{
          AmazonOrderId: this.AmazonOrderIds,
          OrderStatus: 'Shipped',
        }
     })
     .then(res => {
       this.reload();
       console.log(res)
     })
      },
      goUnDealed(){
       for(let i = 0 ; i<this.multipleSelection.length; i++){
      this.AmazonOrderIds.push(this.multipleSelection[i].AmazonOrderId)
      console.log( this.AmazonOrderIds )
      }
        axios({
        method: "post",
        url: html.domain + "orders/updateorderstatus/",
        data:{
          AmazonOrderId: this.AmazonOrderIds,
          OrderStatus: 'UnDealed',
        }
     })
     .then(res => {
       this.reload();
       console.log(res)
     })
      } ,
  },
  mounted(){
  },
  beforeDestroy() {
    clearInterval(this.timertwo);        
    this.timer = null;
    },
  watch: {
    DateValue(newval, oldval) {
      console.log(newval);
      console.log(oldval);
    }
  },
  updata(){
    // this.timers();
    this.getData()
  },
  components: {
    pagination
  }
};
</script>

<style scoped lang="scss">
@import "../../assets/css/them.scss";
.top{
  .sslx{
     color: #409EFF;
      margin-left: 5px;
      cursor:pointer;
  }
  .one{
    span{
      color: #409EFF;
      margin-left: 5px;
      cursor:pointer;
    }
    .action{
      background-color: #409EFF;
      color: white
    }
  }
  .two{
    span{
      color: #409EFF;
      margin-left: 5px;
      cursor:pointer;
    }
    .action{
      background-color: #409EFF;
      color: white
    }
  }
  .srco{
  width: 1680px;
    span{
      display: inline-block;
      color: #409EFF;
      margin-left: 5px;
      cursor:pointer;
    }
    .action{
      background-color: #409EFF;
      color: white
    }
  }
  .guojia{
     color: #409EFF;
      margin-left: 5px;
      cursor:pointer;
  }
  .sslx{
     color: #409EFF;
      margin-left: 5px;
      cursor:pointer;
  }
.action{
  background-color: #409EFF;
      color: white
}
   
}
.container-box {
  .form-box {
    
    padding: 10px 20px;
    border-bottom: 1px solid #ccc;
    .input-box {
      margin-bottom: 20px;
    }
    .input-label div {
      padding: 0px !important;
    }
    .input-label .label {
      margin-top: 4px;
    }
  }
  .button-box {
    margin: 50px;
  }
  .menucss {
    padding-left: 5px;
    width: 200px;
    padding: 5px 0 5px 5px;
  }
  .menu1css {
    float: right;
    padding: 5px 5px 5px 0;
  
    
  }
 .el-select .el-input {
    width: 130px;
  }
  .input-with-select .el-input-group__prepend {
    background-color: #fff;
  }
  
}
</style>